package dao.impl;

import dao.ProvinceDao;
import entity.Province;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.DataSourceUtils;

import java.sql.SQLException;
import java.util.List;

public class ProvinceDaoImpl implements ProvinceDao {

    private QueryRunner qr = new QueryRunner(DataSourceUtils.getDs());

    @Override
    public List<Province> findAll() {
        try {
            return qr.query("select * from province",new BeanListHandler<>(Province.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
